<template>
    <div>
        <el-table :data="tableData" border>
            <el-table-column prop="id" label="用户编号" width="180">
            </el-table-column>
            <el-table-column prop="nickname" label="昵称" width="180">
            </el-table-column>
            <el-table-column prop="phone" label="手机号"> </el-table-column>
            <el-table-column prop="status" label="状态">
                <template slot-scope="item">
                    <el-tag>
                        {{ item.row.status == 1 ? "启用" : "禁用" }}
                    </el-tag>
                </template>
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="item">
                    <el-button
                        type="primary"
                        icon="el-icon-edit"
                        @click="changeBtn(item.row)"
                    >
                        编辑</el-button
                    >
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
import { memberlist } from "../../utils/request/api.js";
export default {
    data() {
        return {
            tableData: [],
        };
    },
    methods: {
        //点击编辑
        changeBtn(row) {
            //发送事件给父组件，让传过去的password为空
            console.log(row.password);
            this.$emit("sendval", row);
            this.$emit("changeBtn", true);
        },
        //更新数据
        async changeData() {
            let res = await memberlist();
            if (res.code == 200) {
                this.tableData = res.list;
            }
        },
    },
    mounted() {
        this.changeData()
    },
};
</script>

<style scoped></style>
